using System;
using UnityEngine;

public class V3S_Player_Script : MonoBehaviour
{
    public float moveSpeed = 0.5f;
    void Start()
    {
        #region 成员方法
        // 求当前向量的标准化向量(归一化单位向量)
        Vector3 vector = new Vector3(1, 1, 1);
        vector.x = 3;
        Vector3 normal = vector.normalized;// 返回一个单位向量
        Debug.Log("magnitude1: " + normal.magnitude);// 打印向量的模
        vector.Normalize();// 使该向量变为单位向量
        Debug.Log("magnitude2: " + vector.magnitude);
        Debug.Log("sqrMagnitude:" + vector.sqrMagnitude);
        #endregion

        #region 静态方法
        // Vector3.forward;
        // Vector3.back;
        // Vector3.right;
        // Vector3.left;
        // Vector3.up;
        // Vector3.down;
        // Vector3.zero;
        // Vector3.one;
        // 求两点间距离
        float distance = Vector3.Distance(Vector3.back, Vector3.forward);
        Debug.Log("distance: " + distance);
        // 求两个向量的夹角
        float angle1 = Vector3.Angle(new Vector3(1,1,0), new Vector3(1,-1, 0));
        float angle2 = Vector3.Angle(new Vector3(1,-1,0), new Vector3(1,1,0));
        Debug.Log("angle1: " + angle1 + " ,angle2: " + angle2);
        // 求两个向量的叉乘(a×b)!=(b×a),判断左右(玩家前方向量与玩家对怪向量叉乘，上怪右，下怪左). 
        Vector3 normalCross = Vector3.Cross(Vector3.forward, new Vector3(1, 1, 0));
        // 求两个向量的点乘,判断前后(玩家前方向量与玩家对怪向量点乘，正怪前，负怪后).
        float dot = Vector3.Dot(Vector3.forward, Vector3.right);
        // 插值
        Vector3 lerpPosition = Vector3.Lerp(Vector3.zero, Vector3.right * 3, 0.5f);
        Debug.Log("LerpPosition:" + lerpPosition);
        #endregion
    }

    private void FixedUpdate()
    {
        transform.position = Vector3.Lerp(transform.position, Vector3.forward * 12, 0.1f * moveSpeed);
    }
}